import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 17655
 * Date: 2025-03-26
 * Time: 17:47
 */
public class test3 {
    /**
     * 现有⼀个数组,数组中的每个元素都是⼀个⼀位数数字,现在要将这个数字(数组组成的数字)加1后输
     * 出,例⼦:[1,2,3]--> [1,2,4] [4,3,2,1]--> [4,3,2,2]
     */

    // 将数组转换成字符串
    public static String change(int[] nums){
        StringBuilder sb = new StringBuilder();
        for(int i=0;i<nums.length;i++){
            sb.append(nums[i]);
        }
        return sb.toString();
    }

    // 将字符串转换成数组
    public static List<Integer> change2(String s){
        List<Integer> result = new ArrayList<>();
        for(char digit:s.toCharArray()){
            result.add(Character.getNumericValue(digit));
        }
        return result;
    }


    public static void main(String[] args) {
        int[] nums = {1,2,3,4};
        for(int i=0;i<nums.length;i++){
            System.out.print("转换前:"+nums[i]);
        }
        String ss = change(nums);
        Integer s = Integer.parseInt(ss);
        s = s+1;
        System.out.println(s);
        ss = String.valueOf(s);
        System.out.println(ss);

        System.out.println(change2(ss));
    }
}
